const AJAX = getApp().ajax,
      $wx = getApp().$wx,
      getColor = getApp().globalData.getColor;

Page({
  data: {
    getColor: getColor()
  },

  onLoad(){
    $wx.setNavColor(getColor().val);  

  },

  onShareAppMessage(){

  },
  
  formSubmit(e){
    let form_obj = e.detail.value;

    if(form_obj.nickname.length > 0){
      wx.showLoading({
        title: '加载中...',
        mask: true
      });

      AJAX.updateNickName({
        user_nick: form_obj.nickname
      },(status, data, msg)=>{
        wx.hideLoading();
        $wx.showToast(msg);
        
        if(status){
          setTimeout(callBack => {
            wx.navigateBack();
          }, 2000);
        }
      });
    }else{
      $wx.showToast('请输入昵称');
    }
  }
});
